#pragma once
#include<stdio.h>
#include<windows.h>
#include<stdbool.h>
#include<time.h>

typedef struct snakenode {
	int x;
	int y;
	struct snakenode* next;
}snakenode,* psnakenode;

enum Direction {
	UP=1,
	DOWN,
	LEFT,
	RIGHT
};

enum GameState {
	OK,
	KILL_BY_WALL,
	KILL_BY_SELF,
	END_NORMAL
};

typedef struct Snake {
	psnakenode _psnake;
	psnakenode _pfood;
	enum Direction dir;
	enum GameState gs;
	int food_weight;
	int score;
	int sleep_time;
}Snake,*psnake;

void GameStart(psnake ps);
void GameRun(psnake ps);
void Snakemove(psnake ps);
int NextIsFood(psnakenode pn, psnake ps);
void KillByWall(psnake ps);
void KillBySelf(psnake ps);
void EatFood(psnakenode pn, psnake ps);
void GameEnd(psnake ps);